import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'esc_command.dart';
import 'flutter_k9_platform_interface.dart';

/// An implementation of [FlutterK9Platform] that uses method channels.
class MethodChannelFlutterK9 extends FlutterK9Platform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('flutter_k9');

  @override
  Future<String?> getPlatformVersion() async {
    final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
    return version;
  }

  @override
  Future<bool?> connect() async{
    return await methodChannel.invokeMethod<bool>('connect');
  }
  @override
  Future<bool?> print(List<EscCommand> commands) async{
    var maps = commands.map((e) => e.toJson()).toList();
    final result = await methodChannel.invokeMethod<bool>("print", {
      "commands": maps,
    });
    return result;
  }
}
